<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" template="/templates/layout.xhtml">

	<ui:define name="ptitle">组织机构管理</ui:define>
	<ui:define name="pcontent">
		<h:form id="frm" >
    		<p:contextMenu for="vorgs">
		        <p:menuitem value="查看" update="msgs" actionListener="#{sysOrganMB.displaySelectedSingle}" icon="ui-icon-search" />
		        <p:menuitem value="增加" update="msgs" actionListener="#{sysOrganMB.displaySelectedSingle}" icon="ui-icon-plus"/>
		        <p:menuitem value="删除" update="vorgs" actionListener="#{sysOrganMB.deleteNode}" icon="ui-icon-minus"/>
		    </p:contextMenu>
			<p:growl id="msgs" showDetail="true" />			
			<p:treeTable id="vorgs" value="#{sysOrganMB.root}" var="vorg"
				selectionMode="single" selection="#{sysOrganMB.selectedNode}" style="margin-top:0">
				
				<p:ajax event="expand" update=":frm:msgs" listener="#{sysOrganMB.displaySelectedSingle}" />
		        <p:ajax event="collapse" update=":frm:msgs" listener="#{sysOrganMB.displaySelectedSingle}" />
		        <p:ajax event="select" update=":frm:msgs" listener="#{sysOrganMB.displaySelectedSingle}" />
		        <p:ajax event="unselect" update=":frm:msgs" listener="#{sysOrganMB.displaySelectedSingle}" />
			        
		        <f:facet name="header">企业组织机构信息</f:facet>
		        <p:column headerText="名称">
		            <h:outputText value="#{vorg.name}" />
		        </p:column>
		        <p:column headerText="部门ID">
		            <h:outputText value="#{vorg.orgid}" />
		        </p:column>
		        <p:column headerText="类型">
		            <h:outputText value="#{vorg.dtype}" />
		        </p:column>
		        <p:column headerText="用户ID">
		            <h:outputText value="#{vorg.userid}" />
		        </p:column>
		        <p:column style="width:24px">
		            <p:commandLink update=":frm:deptPanel" oncomplete="PF('deptDialog').show()" title="View Detail" styleClass="ui-icon ui-icon-search">
		                <f:setPropertyActionListener value="#{vorg}" target="#{sysOrganMB.selectedNodeData}" />
		            </p:commandLink>
		        </p:column>
		    </p:treeTable>

		    <p:dialog id="dialog" header="部门信息详情" showEffect="fade" widgetVar="deptDialog"  resizable="false">
		        <p:outputPanel id="deptPanel">
		            <p:panelGrid  columns="2" columnClasses="label,value" rendered="#{not empty sysOrganMB.selectedNodeData}">
		                <h:outputLabel for="dorgid" value="部门ID: " />
		                <h:outputText id="dorgid" value="#{sysOrganMB.selectedNodeData.orgid}" style="font-weight:bold" /> 
		                <h:outputLabel for="dname" value="部门名称: " />
		                <h:outputText id="dname" value="#{sysOrganMB.selectedNodeData.name}" style="font-weight:bold" /> 
		                <h:outputLabel for="dtype" value="类型: " />
		                <h:outputText id="dtype" value="#{sysOrganMB.selectedNodeData.dtype}" style="font-weight:bold" />
		                <h:outputLabel for="duserid" value="用户ID: " />
		                <h:outputText id="duserid" value="#{sysOrganMB.selectedNodeData.userid}" style="font-weight:bold" />
		            </p:panelGrid>
		        </p:outputPanel>
		    </p:dialog>
		    
		    <br />
		    <h:panelGrid columns="2" >
				<p:panel  header="企业组织机构信息" style="height:360px;" >				
				<p:tree id="iorgs" value="#{sysOrganMB.root}" var="iorg" 
					selectionMode="single" selection="#{sysOrganMB.selectedNode}">		
								
					<p:ajax event="expand" update=":frm:msgs" listener="#{sysOrganMB.displaySelectedSingle}" />
			        <p:ajax event="collapse" update=":frm:msgs" listener="#{sysOrganMB.displaySelectedSingle}" />
			        <p:ajax event="select" update=":frm:msgs  :frm:iporg" listener="#{sysOrganMB.displaySelectedSingle}" />
			        <p:ajax event="unselect" update=":frm:msgs" listener="#{sysOrganMB.displaySelectedSingle}" />
			        
					<p:treeNode expandedIcon="ui-icon-folder-open" collapsedIcon="ui-icon-folder-collapsed" >
						<h:outputText value="#{iorg.name}" />
					</p:treeNode>
    				<p:treeNode type="usernodes" icon="ui-icon-image">
				        <h:outputText value="#{iorg.name}" />
				    </p:treeNode> 
				     				    
				</p:tree>
				</p:panel>
				<p:panel  header="部门信息/人员信息" style="height:360px;">
					<p:panelGrid id="iporg" columns="2" columnClasses="label,value" >
		                <h:outputLabel for="idorgid" value="部门ID: " />
		                <h:outputText id="idorgid" value="#{sysOrganMB.selectedNodeData.orgid}" style="font-weight:bold" /> 
		                <h:outputLabel for="idname" value="部门名称: " />
		                <h:outputText id="idname" value="#{sysOrganMB.selectedNodeData.name}" style="font-weight:bold" /> 
		                <h:outputLabel for="idtype" value="类型: " />
		                <h:outputText id="idtype" value="#{sysOrganMB.selectedNodeData.dtype}" style="font-weight:bold" />
		                <h:outputLabel for="iduserid" value="用户ID: " />
		                <h:outputText id="iduserid" value="#{sysOrganMB.selectedNodeData.userid}" style="font-weight:bold" />
		            </p:panelGrid>
	
				</p:panel>
				
			</h:panelGrid>
			<p:contextMenu for="iorgs">
		        <p:menuitem value="查看" update="msgs" actionListener="#{sysOrganMB.displaySelectedSingle}" icon="ui-icon-search" />
		        <p:menuitem value="增加" update="msgs" actionListener="#{sysOrganMB.displaySelectedSingle}" icon="ui-icon-plus"/>
		        <p:menuitem value="删除" update="iorgs" actionListener="#{sysOrganMB.deleteNode}" icon="ui-icon-minus"/>
		    </p:contextMenu>
		    
		</h:form>

	</ui:define>
</ui:composition>

